package com.ktvme.MqTest

import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@SpringBootApplication
class MqTestApplication {

    private static int roomNum = 100

    @PostMapping("/send_json")
    def sendJson() {
        def data = RoomStateHelper.genRoomStates(roomNum)
        [ret: 0, msg: "伪造房态生成成功", data: data]
    }

    @PostMapping("/lazy_send_json")
    def lazySendJson() {
        def data = RoomStateHelper.genRoomStates(roomNum)
        [ret: 0, msg: "伪造房态生成成功", data: data]
    }

    @GetMapping("/room_num")
    def getRoomNum() {
        [ret: 0, msg: "OK", data: roomNum]
    }

    @PostMapping("/room_num/{value}")
    def setRoomNum(@PathVariable(value = "value") Integer value) {
        roomNum = value
        [ret: 0, msg: "OK", data: roomNum]
    }

    static void main(String[] args) {
        SpringApplication.run MqTestApplication, args
    }
}
